<template>
  <div class="nav">
    <div>
      <el-menu
        :default-active="active"
        class="el-menu-demo"
        mode="horizontal"
        background-color="pink"
        text-color="#fff"
        active-text-color="#0ff"
        @select="handleSelect"
      >
        <el-menu-item index="/nav/we">我们</el-menu-item>
        <!-- <div class="flex-grow" /> -->
        <!-- <el-sub-menu index="2">
      <template #title>Workspace</template>
      <el-menu-item index="2-1">item one</el-menu-item>
      <el-menu-item index="2-2">item two</el-menu-item>
      <el-menu-item index="2-3">item three</el-menu-item>
      <el-sub-menu index="2-4">
        <template #title>item four</template>
        <el-menu-item index="2-4-1">item one</el-menu-item>
        <el-menu-item index="2-4-2">item two</el-menu-item>
        <el-menu-item index="2-4-3">item three</el-menu-item>
      </el-sub-menu>
    </el-sub-menu> -->
        <!-- <el-menu-item index="3">你们</el-menu-item> -->

        <el-menu-item index="/nav/imgWarehouse">照片仓库</el-menu-item>

        <el-menu-item index="/nav/imgMarket">照片市场</el-menu-item>

        <el-menu-item v-if="`${userId}` === '1'" index="/nav/userAdmin">
          用户管理
        </el-menu-item>

        <el-menu-item index="/nav/photoWall"> 照片墙 </el-menu-item>

        <el-menu-item index="/nav/anonymousMessage"> 匿名留言 </el-menu-item>
      </el-menu>
    </div>
  </div>
</template>

<script>
export default {
  components: {
  },
  data () {
    return {
      userId: '',
      active: '/nav/we'
    };
  },
  mounted () {
    this.active = this.$route.path
    this.userId = sessionStorage.getItem('userId')
  },
  methods: {
    handleSelect (key, keyPath) {
      console.log(key, keyPath);
      this.$router.push({ path: key })
    }
  }
};
</script>

<style scoped>
.flex-grow {
  flex-grow: 1;
}
.nav {
  background-color: pink;
}
</style>
